<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Touch
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 * @version    $Id: request-friend.tpl 2011-04-26 11:18:13 mirlan $
 * @author     Mirlan
 */

?>
<script type="text/javascript">
  var userWidgetRequestSend = function(action, user_id, notification_id)
  {
    var url;
    if( action == 'confirm' )
    {
      url = '<?php
						echo $this->url ( array ('controller' => 'friends', 'action' => 'confirm' ), 'user_extended', true )?>';
    }
    else if( action == 'reject' )
    {
      url = '<?php
						echo $this->url ( array ('controller' => 'friends', 'action' => 'reject' ), 'user_extended', true )?>';
    }
    else
    {
      return false;
    }

    (new Request.JSON({
      'url' : url,
      'data' : {
        'user_id' : user_id,
        'format' : 'json',
        'token' : '<?php
								echo $this->token ()?>'
      },
      'onSuccess' : function(responseJSON)
      {
        if( !responseJSON.status )
        {
          $('user-widget-request-' + notification_id).innerHTML = responseJSON.error;
        }
        else
        {
          $('user-widget-request-' + notification_id).innerHTML = responseJSON.message;
        }
      }
    })).send();
  }
</script>

<li
	id="user-widget-request-<?php
	echo $this->notification->notification_id?>">
<div class="item_photo">
  	<?php
			echo $this->itemPhoto ( $this->notification->getSubject (), 'thumb.icon' )?>
	</div>
<div class="item_body">
<div>
      <?php
						echo $this->translate ( '%1$s has sent you a friend request.', $this->htmlLink ( $this->notification->getSubject ()->getHref (), $this->notification->getSubject ()->getTitle () ) );
						?>
    </div>
<div>
<button type="submit"
	onclick='userWidgetRequestSend("confirm", <?php
	echo $this->notification->getSubject ()->getIdentity ()?>, <?php
	echo $this->notification->notification_id?>)'>
        <?php
								echo $this->translate ( 'Add Friend' );
								?>
      </button>
      <?php
						echo $this->translate ( 'or' );
						?>
      <a href="javascript:void(0);"
	onclick='userWidgetRequestSend("reject", <?php
	echo $this->notification->getSubject ()->getIdentity ()?>, <?php
	echo $this->notification->notification_id?>)'>
        <?php
								echo $this->translate ( 'ignore request' );
								?>
      </a></div>
</div>
</li>